﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication5.settings
{
    public class Routerconfig
    {
        /*
         * Getter und Setter
         */
        public String Hostname { get; set; }
        public String Motd { get; set; }
        public Boolean Console_pw_enabled { get; set; }
        public String Console_pw { get; set; }
        public Boolean Telnet_pw_enabled { get; set; }
        public String Telnet_pw { get; set; }
        public String User_name { get; set; }
        public Boolean User_pw_enabled { get; set; }
        public String User_pw { get; set; }

        public Routerconfig(String host, String message, Boolean c_pw_enabled, String c_pw, Boolean t_pw_enabled, String t_pw, Boolean u_pw_enabled, String u_name, String u_pw)
        {
            Hostname = host;
            Motd = message;
            Console_pw_enabled = c_pw_enabled;
            Console_pw = c_pw;
            Telnet_pw_enabled = t_pw_enabled;
            Telnet_pw = t_pw;
            User_name = u_name;
            User_pw_enabled = u_pw_enabled;
            User_pw = u_pw;
        }

        public Routerconfig()
        {
        }

        /**
         * Baut den Ausgabe-String für die Grundkonfiguration-Konfiguration zusammen
         * und gibt ihn zurück
         */
        public String toString()
        {
            String ret = "";

            // Hostname
            ret += "hostname " + Hostname + Environment.NewLine;

            // MotD
            if (Motd != "")
            {
                ret += "banner motd " + Motd + Environment.NewLine;
                ret += "!" + Environment.NewLine;
            }

            // Telnetpasswort
            if (Telnet_pw_enabled == true)
            {
                ret += "enable secret " + Telnet_pw + Environment.NewLine;
                ret += "!" + Environment.NewLine;
            }

            // Konsolenpasswort
            if (Console_pw_enabled == true)
            {
                ret += "line con 0" + Environment.NewLine;
                ret += " password " + Console_pw + Environment.NewLine;
                ret += " login" + Environment.NewLine;
                ret += "!" + Environment.NewLine;
            }

            // Configure Local User-Specific Passwords
            if (User_pw_enabled == true)
            {
                ret += "line vty 0 4" + Environment.NewLine;
                ret += " username " + User_name + " password " + User_pw + Environment.NewLine;
                ret += " login local" + Environment.NewLine;
                ret += "!" + Environment.NewLine;
            }

            return ret;
        }

    }

}
